﻿using System.Linq;
using System.Collections.Generic;
using EPiServer.Core;
using OpenWaves.EPiServer;
using OpenWaves.Navigation.EPiServer;

namespace $rootnamespace$.Controls
{
    public class NavigationNode : IEPiNavigationNode<NavigationNode>
    {
        public readonly PageData Page;

        public NavigationNode(PageData page)
        {
            this.Page = page;
        }

        public PageReference PageLink
        {
            get { return new PageReference(this.Page.ContentLink.ID); }
        }

        public string Name
        {
            get { return this.Page.Name; }
        }

        public string Url
        {
            get { return this.Page.LinkURL; }
        }

        public bool IsVisibleInMenu
        {
            get { return this.Page.VisibleInMenu; }
        }

        public IEnumerable<NavigationNode> Children
        {
            get { return this.Page.GetChildren().Select(p => new NavigationNode(p)); }
        }
    }
}